package com.cloud.aiservice.service.impl;

import java.time.LocalDate;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.cloud.aiservice.dao.es.NewsRawEsRepostory;
import com.cloud.aiservice.service.NewsSearchService;

@Service
public class NewsSearchServiceESImpl implements NewsSearchService{
	private final RestHighLevelClient rhlc;
	private final NewsRawEsRepostory newsRawEsRepostory;
	
	public NewsSearchServiceESImpl(RestHighLevelClient rhlc,NewsRawEsRepostory newsRawEsRepostory) {
		this.rhlc = rhlc;
		this.newsRawEsRepostory=newsRawEsRepostory;
	}

	@Override
	public String getNewsByKeyword(String keyword) {
		var res=newsRawEsRepostory.findByTitle(keyword);
		
		return JSON.toJSONString(res);
	}

	@Override
	public String getNewsByDateRange(LocalDate startDate, LocalDate endDate) {
		// TODO 根据日期获取文章
		return null;
	}

}
